package com.xiyoufang.club.repository;

import java.util.List;

import com.xiyoufang.club.pojo.UserInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public abstract interface UserInfoRepository
        extends JpaRepository<UserInfo, Integer>, JpaSpecificationExecutor<UserInfo> {
    public abstract UserInfo findByUserId(String paramString);

  //  public abstract UserInfo findByOpenid(String paramString);

  //  public abstract UserInfo findByUnionid(String paramString);

    @Query(nativeQuery = true, value = "SELECT user_id as userId,nick_name as nickName,gold_num as goldNum, headimgurl as headImgUrl FROM t_user_info order by gold_num desc LIMIT 30 ")
    public abstract List findGoldNumRanking();

    @Query(nativeQuery = true, value = "SELECT user_id as userId,nick_name as nickName,gold_num as goldNum, headimgurl as headImgUrl FROM t_user_info order by gold_num desc LIMIT :num ")
    public abstract List findGoldRanking(@Param("num") Integer paramInteger);

    @Query(nativeQuery = true, value = "SELECT user_id as userId,nick_name as nickName,room_card_num as roomCard, headimgurl as headImgUrl FROM t_user_info order by room_card_num desc LIMIT 30 ")
    public abstract List findRoomCardRanking();

    @Query(nativeQuery = true, value = "SELECT * FROM t_user_info WHERE gameNickName=:gameNickName")
    public abstract UserInfo findByGameNickName(@Param("gameNickName") String paramString);
}
